<template>
	<!--产品数据-->
	<view class="com-content">
		<view class="com-top2">
			<image class="com-body-img" :src="obj.pro_img" ></image>
			<view class="com-body-box">
				<view class="box-name">{{obj.pro_name}}</view>
				<view class="box-txt" v-if="pageType==='pop'">
					<block v-for="(item,iii) in obj.pro_txt" :key="iii">
						<view class="box-txt-li">{{item}}</view>
					</block>
				</view>
				<view class="box-remark">备注：{{obj.remark}}</view>
			</view>
		</view>
		<view class="com-body">
			<block v-for="(item,index) in obj.datalist" :key="index">
				<view class="com-body-li" v-if="pageType==='pop' || pageType==='prop'">
					<view class="li-title"><text class="li-title-t">{{item.pro_name}}</text></view>
					<block v-for="(ite,ind) in item.list" :key="ind">
						<template v-if="ite.type===1&&pageType==='pop'">
							<view class="li-box">{{ite.name}}</view>
							<block v-for="(it,i) in ite.list" :key='i'>
								<view class="li-box-li">
									<view class="li-box-o">{{it.name}}</view>
									<view class="li-box-t" v-if="it.is_edit===2">
										<view class="li-box-w">{{it.sizew}}</view>x
										<view class="li-box-w">{{it.sizeh}}</view>
									</view>
									<view class="li-box-t" v-else-if="it.is_edit===1">
										<input class="input-row-w" type="number" v-model="it.sizew" placeholder="长度(cm)"
											placeholder-style="color:#ddd;font-size:20rpx;"></input>x
										<input class="input-row-w" type="number" v-model="it.sizeh" placeholder="长度(cm)"
											placeholder-style="color:#ddd;font-size:20rpx"></input>
									</view>
									<view class="li-box-th">
										<image class="icon-jj" v-if="it.num>0" :src="$mAssetsPath.icon_jianhao"
											@click="rednum1(index,ind,i)"></image>
										<view class="li-box-th-num" v-if="it.num>0">{{it.num}}</view>
										<image class="icon-jj" :src="$mAssetsPath.icon_jiahao"
											@click="addnum1(index,ind,i)"></image>
									</view>
								</view>
							</block>
						</template>
						<template v-else-if="ite.type===2&&pageType==='pop'">
							<view class="li-box-li2">
								<view class="li-box-o">{{ite.name}}</view>
								<view class="li-box-t" v-if="ite.is_edit===2">
									<view class="li-box-w">{{ite.sizew}}</view>x
									<view class="li-box-w">{{ite.sizeh}}</view>
								</view>
								<view class="li-box-t" v-else-if="ite.is_edit===1">
									<input class="input-row-w" type="number" v-model="ite.sizew" placeholder="长度(cm)"
										placeholder-style="color:#ddd;font-size:20rpx;"></input>x
									<input class="input-row-w" type="number" v-model="ite.sizeh" placeholder="长度(cm)"
										placeholder-style="color:#ddd;font-size:20rpx"></input>
								</view>
								<view class="li-box-th">
									<image class="icon-jj" v-if="ite.num>0" :src="$mAssetsPath.icon_jianhao"
										@click="rednum2(index,ind)"></image>
									<view class="li-box-th-num" v-if="ite.num>0">{{ite.num}}</view>
									<image class="icon-jj" :src="$mAssetsPath.icon_jiahao" @click="addnum2(index,ind)">
									</image>
								</view>
							</view>
						</template>
						<template v-else-if="pageType==='prop'">
							<view class="li-box-li2">
								<view class="li-box-o">{{ite.name}}</view>
								<view class="li-box-th">
									<image class="icon-jj" v-if="ite.num>0" :src="$mAssetsPath.icon_jianhao"
										@click="rednum2(index,ind)"></image>
									<view class="li-box-th-num" v-if="ite.num>0">{{ite.num}}</view>
									<image class="icon-jj" :src="$mAssetsPath.icon_jiahao" @click="addnum2(index,ind)">
									</image>
								</view>
							</view>
						</template>
					</block>
					<template v-if="pageType==='pop'">
						<template v-if="item.texture && item.texture.length>0">
							<view class="li-texture" @click="sel_mat(index)">材质：
								<block v-for="(li,ii) in item.texture" :key="ii">
									<view class="li-texture-txt">{{li}}</view>
								</block>
							</view>
						</template>
						<template v-else>
							<image class="li-texture-bot" @click="sel_mat(index)" :src="$mAssetsPath.icon_add_but"></image>
						</template>
					</template>
				</view>

			</block>
			<view class="com-body-count" v-if="obj.count_money">
				<view class="count-name">供应商：<text class="count-name-txt">{{obj.sup_name}}</text></view>
				<view class="count-money">金额：¥{{obj.count_money}}</view>
			</view>
		</view>
		<w-popup :show="showtip" :type="type1" @change="change1">
			<view class="w-tip">
				<view class="w-tit">设置定制</view>
				<scroll-view class="w-con" :scroll-top="scrollTop2" scroll-y="true">
					<view class="w-con-t">材质：</view>
					<view class="w-con-c">
						<block v-for="(item,index) in list" :key="index">
							<view class="w-con-c-li" @click="choose(index)"
								:style="{background:item.statu?'#CBE6FF':'#f5f5f5',color:item.statu?'#198FFF':'#999'}">
								{{item.name}}</view>
						</block>
					</view>
				</scroll-view>
				<view class="w-but">
					<view class="w-but-txt" @click="cancel('tip')">取消</view>
					<view class="w-but-txt" @click="confirm">确认</view>
				</view>
			</view>
		</w-popup>
	</view>
</template>

<script>
	import wPopup from '@/components/w-popup/w-popup2.vue';
	export default {
		name: "com-top",
		components: {
			wPopup
		},
		props: {
			obj: {
				type: Object,
				default () {
					return {
						count_money: 999,
						sup_name: '供应商一',
						pro_img: '/static/data-img/img.jpg',
						pro_name: 'XX系列图片系列图片系列图片',
						pro_txt: ['男', '鞋', '都市'],
						remark: '此订单需注意尺寸',
						datalist: [{
							pro_name: '橱窗',
							texture: ['塑料', '玻璃', '棉'],
							list: [{
								type: 1,
								name: '玻璃贴',
								list: [{
									name: '玻璃左',
									sizew: '570',
									sizeh: '370',
									num: 1
								}, {
									name: '玻璃右',
									sizew: '570',
									sizeh: '370',
									num: 1
								}, ]
							}, {
								name: '背景海报',
								type: 2,
								sizew: '500',
								sizeh: '370',
								num: 3
							}, {
								name: '道具POP',
								type: 2,
								sizew: '500',
								sizeh: '370',
								num: 3
							}]
						}]
					}
				}
			},
			pageType: {
				type: String,
				default: 'pop'
			},
			list: {
				type: Array,
				default () {
					return [{
						name: '塑料'
					}, {
						name: '黑胶玻璃贴'
					}, {
						name: '皮革'
					}, {
						name: '纸'
					}, {
						name: '丝绸'
					}, {
						name: '棉丝皮革纸'
					}, {
						name: '塑料'
					}, {
						name: '黑胶玻璃贴'
					}, {
						name: '皮革'
					}, {
						name: '纸'
					}, {
						name: '丝绸'
					}, {
						name: '棉丝皮革纸'
					}, {
						name: '塑料'
					}, {
						name: '黑胶玻璃贴'
					}, {
						name: '皮革'
					}, {
						name: '纸'
					}, {
						name: '丝绸'
					}, {
						name: '棉丝皮革纸'
					}, {
						name: '塑料'
					}, {
						name: '黑胶玻璃贴'
					}, {
						name: '皮革'
					}, {
						name: '纸'
					}, {
						name: '丝绸'
					}, {
						name: '棉丝皮革纸'
					}]
				}
			}
		},
		data() {
			return {
				showtip: false, //是否显示弹窗1
				content1: '顶部弹 popup',
				type1: '', //弹窗显示方式
				scrollTop2: 0,
				sel_ind: 0
			}
		},
		methods: {
			choose(index) {
				this.$emit('choose', index);
			},
			confirm() {
				let list = []
				if (this.list && this.list.length > 0) {
					this.list.forEach((item, ind) => {
						if (item.statu) {
							list.push(item.name)
						}
					})
				}
				this.$emit('confirm', list, this.sel_ind);
				this.showtip = false;
			},

			//选择定制材质
			sel_mat(index) {
				this.$emit('sel_mat');
				this.sel_ind = index;
				this.content1 = 'center'
				this.type1 = 'center';
				this.showtip = true;
			},
			//一级减少
			rednum2(index, index2) {
				this.$emit('rednum2', index, index2)
			},
			//一级增加
			addnum2(index, index2) {
				this.$emit('addnum2', index, index2)
			},
			//二级减少
			rednum1(index, index2, index3) {
				this.$emit('rednum1', index, index2, index3)
			},
			//二级增加
			addnum1(index, index2, index3) {
				this.$emit('addnum1', index, index2, index3)
			},
			change1(e) {
				if (!e.show) {
					this.showtip = false;
				}
			},
			//取消
			cancel(type) {
				this['show' + type] = false
			},
		}
	}
</script>

<style lang="scss" scoped>
	/* 提示窗口 */
	.w-tip {
		/* #ifndef APP-NVUE */
		display: flex;
		flex-direction: column;
		/* #endif */
		width: 80vw;
		min-height: 300rpx;
		border-radius: 10rpx;
		background-color: #fff;
		box-shadow: 0rpx 7rpx 7rpx 0rpx rgba(0, 0, 0, 0.1);
		margin: 30rpx auto 0;

		.w-tit {
			font-size: 36rpx;
			font-weight: bold;
			color: $font-color-3;
			line-height: 90rpx;
			height: 90rpx;
			text-align: center;
			border-bottom: 1rpx solid #f5f5f5;
		}

		.w-but {
			display: flex;
			font-size: 32rpx;
			font-weight: 400;
			color: $font-color-b3;
			height: 84rpx;
			line-height: 84rpx;

			.w-but-txt {
				flex: 1;
				text-align: center;
				border-right: 1rpx solid #f5f5f5;
			}

			.w-but-txt:last-of-type {
				border-right: none;
			}
		}

		.w-con {
			display: flex;
			flex-direction: column;
			height: 400rpx;
			font-size: 32rpx;
			font-weight: 400;
			color: $font-color-3;
			border-bottom: 1rpx solid #f5f5f5;

			.w-con-t {
				font-size: 28rpx;
				font-weight: 400;
				color: $font-color-3;
				padding: 10rpx 30rpx;
			}

			.w-con-c {
				display: flex;
				flex-wrap: wrap;
				padding: 10rpx 30rpx;

				.w-con-c-li {
					height: 52rpx;
					line-height: 52rpx;
					padding: 0 20rpx;
					margin: 0 20rpx 20rpx 0;
					border-radius: 6rpx;
					font-size: 28rpx;
					font-weight: 400;
				}
			}
		}
	}

	.com-content {
		display: flex;
		flex-direction: column;
		width: 100%;
		padding: 30rpx 30rpx 0 30rpx;

		.com-top2 {
			display: flex;
			flex-direction: column;
			margin-bottom: 30rpx;

			.com-body-img {
				width: 100%;
				height: 388rpx;
				border-radius: 10rpx;
				margin-bottom: 30rpx;
				overflow: hidden;
			}

			.com-body-box {
				display: flex;
				flex-direction: column;
				border-bottom: 1rpx solid #f5f5f5;

				.box-name {
					font-size: 32rpx;
					font-weight: 400;
					color: $font-color-3;
					margin-bottom: 26rpx;
				}

				.box-txt {
					display: flex;
					margin-bottom: 26rpx;

					.box-txt-li {
						height: 38rpx;
						line-height: 38rpx;
						font-size: 24rpx;
						font-weight: 400;
						color: $font-color-9;
						padding: 0 20rpx;
						background: $uni-bg-color-grey;
						border-radius: 4rpx;
						margin-right: 20rpx;
					}
				}

				.box-remark {
					padding: 20rpx 0;
					border-top: 1rpx solid #f5f5f5;
					font-size: 28rpx;
					font-weight: 400;
					color: #FE5252;
				}
			}
		}

		.com-body {
			display: flex;
			flex-direction: column;

			.com-body-count {
				display: flex;
				justify-content: space-between;

				.count-name {
					font-size: 28rpx;
					font-weight: 400;
					line-height: 40rpx;
					color: $font-color-3;

					.count-name-txt {
						color: $font-color-9;
					}
				}

				.count-money {
					font-size: 28rpx;
					font-weight: 400;
					line-height: 40rpx;
					color: #FE5252;
				}
			}

			.li-texture {
				display: flex;
				border-top: 1rpx solid #f5f5f5;
				border-bottom: 1rpx solid #f5f5f5;

				.li-texture-txt {
					margin-right: 30rpx;
				}
			}

			.li-texture-bot {
				width: 84rpx;
				height: 52rpx;
			}

			.com-body-li {
				display: flex;
				flex-direction: column;
				margin-bottom: 20rpx;
				font-size: 28rpx;
				font-weight: 400;
				line-height: 80rpx;
				color: $font-color-3;

				.li-box-li {
					display: flex;
					justify-content: center;
					align-items: center;

					.li-box-o {
						padding-left: 30rpx;
						flex: 25;
					}

					.li-box-t {
						flex: 50;
						display: flex;
						align-items: center;
						justify-content: center;
						color: $font-color-9;

						.li-box-w {
							margin: 0 10rpx;
						}

						.input-row-w {
							margin: 0 10rpx;
							padding: 0 10rpx;
							width: 120rpx;
							height: 52rpx;
							border: 1rpx solid #EEEEEE;
							border-radius: 6rpx;
							font-size: 28rpx;
						}
					}

					.li-box-th {
						flex: 25;
						display: flex;
						align-items: center;
						justify-content: flex-end;

						.li-box-th-num {
							width: 60rpx;
							text-align: center;
							color: $font-color-b3;
						}

						.icon-jj {
							width: 42rpx;
							height: 42rpx;
						}
					}
				}

				.li-box-li2 {
					display: flex;
					justify-content: center;
					align-items: center;

					.li-box-o {
						padding-right: 30rpx;
						flex: 25;
					}

					.li-box-t {
						flex: 50;
						display: flex;
						align-items: center;
						justify-content: center;
						color: $font-color-9;

						.li-box-w {
							margin: 0 10rpx;
						}

						.input-row-w {
							margin: 0 10rpx;
							padding: 0 10rpx;
							width: 120rpx;
							height: 52rpx;
							border: 1rpx solid #EEEEEE;
							border-radius: 6rpx;
							font-size: 28rpx;
						}
					}

					.li-box-th {
						flex: 25;
						display: flex;
						align-items: center;
						justify-content: flex-end;

						.li-box-th-num {
							width: 60rpx;
							text-align: center;
							color: $font-color-b3;
						}

						.icon-jj {
							width: 42rpx;
							height: 42rpx;
						}
					}
				}

				.li-title {
					display: flex;
					margin-bottom: 20rpx;

					.li-title-t {
						padding: 0 10rpx;
						background: #CBE6FF;
						border-radius: 6rpx;
						font-size: 32rpx;
						line-height: 52rpx;
						color: $font-color-3;

					}
				}
			}
		}
	}
</style>
